

#include <iostream>
#include <cassert>
#include "node.hpp"
#include "app.hpp"

#include "component_sprite.hpp"
using namespace std;

#ifdef main
#undef main
#endif

#include <fstream>
#include <string>
#include <sstream> //string stream

int main( int argv, char** argc ) {
    App app;
    app.init( u8"test", 320,240, 80, 60 );

    //base
    auto& base = *( new Node( "base" ) );
    base.position.x = app.view->__designSize.width / 2;
    base.position.y = app.view->__designSize.height / 2;
    app.root->addChild( base );

    int width  = 8;
    int height = 5;
    int total  = width * height;
    PointFloat p;
    p.x = -width*15 + 15;
    p.y = -height*15 + 15;

    for ( int i = 0; i < total; i++ ) {
        auto& box = *( new Node( "pic" ) );
        auto& sprite = box.addComponent<ComponentSprite>();
        sprite.setTexture( "../assets/box.png" );
        box.position.set(
            p.x + 30 * ( (int)i % width ),
            p.y + 30 * floor( i / (int)width )
        );
        base.addChild( box );
    }

    app.showDebug = 1;
    app.run();

    cin.get();
    return 0;
}